﻿Imports System.Data.SqlClient

Public Class WebForm2
    Inherits System.Web.UI.Page
    'Dim connectionString As String = "Data Source=(localdb)\Projects;Initial Catalog=CIS441WinterParkWeb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False"
    Dim connectionString As String = "Data Source=SHANK-PC\SQLEXPRESS;Initial Catalog=WinterPark;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False"
    Dim con As New SqlConnection(connectionString)

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        TextBox4.Visible = False
        Dim UName As String = TextBox1.Text
        Dim FName As String = TextBox2.Text
        Dim DOB As String = TextBox3.Text

        Dim LoginStatement As String = "SELECT Login.UserName, Login.Password, CustomerTable.FirstName, CustomerTable.BirthDate " & _
                                       "FROM Login, CustomerTable"
        Dim LoginDataAdapter As New SqlDataAdapter(LoginStatement, con)
        Dim LoginDataSet As New DataSet
        LoginDataAdapter.Fill(LoginDataSet, "Login")

        Dim dr As DataRow
        For Each dr In LoginDataSet.Tables("Login").Rows
            If dr.Item("UserName") = UName Then
                If dr.Item("FirstName") = FName Then
                    If dr.Item("BirthDate") = DOB Then
                        Label1.Visible = True
                        ListBox1.Visible = True
                        ListBox1.Items.Add(dr.Item("Password"))
                    Else
                        TextBox4.Visible = True
                    End If
                End If
            End If
        Next dr
        'Dim dr As DataRow
        'For Each dr In LoginDataSet.Tables("Login").Rows
        'If dr.Item("UserName") = UName And dr.Item("FirstName") = FName And dr.Item("BirthDate") = DOB Then
        'Label1.Visible = True
        'ListBox1.Visible = True
        'ListBox1.Items.Add(dr.Item("Password"))
        'Else
        'TextBox4.Visible = True
        'End If
        'Next dr
    End Sub
End Class